package com.eascs.fp.applyLoan.controller;


import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.app.dao.PageResult;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.finance.admin.common.entity.ArticleEntity;
import com.eascs.finance.admin.common.entity.ArticleItemEntity;
import com.eascs.finance.admin.common.service.IArticlefoService;
import com.eascs.finance.admin.common.vo.ArticleQueryVO;
import com.eascs.fp.applyLoan.vo.ArticleVO;
import com.eascs.fp.common.controller.BaseMasterViewController;
import com.eascs.site.view.ViewContext;


@Controller
public class ApplyLoanController extends BaseMasterViewController {
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Reference
	private IArticlefoService articlefoService;
	
	@RequestMapping(value = "/loanApply/index")
	public String loanIndex() {
		try {
			List<ArticleVO> article=new ArrayList<>();
			ArticleQueryVO vo=new ArticleQueryVO();
			vo.setPageSize(5);
			List<ArticleItemEntity> list=articlefoService.getArticleItemList();
			for (ArticleItemEntity item:list) {
				vo.setItemId(item.getId());
				PageResult<ArticleEntity> page = articlefoService.findFrontArticleInfo(vo);
				article.add(new ArticleVO(item, page.getData()));
			}
			ViewContext.put("article1", article.get(0));
			ViewContext.put("article2", article.get(1));
		} catch (Exception e) {
			logger.info("loanIndex error[{}]", e.getMessage());
		}
		
		ViewContext.put("hotHM", "indexHM");
		return "/applyLoan/index";
	}
	
	@RequestMapping(value = "/loanApply/list")
	public String loanList() {
		ViewContext.put("hotHM", "loanDetailsHM");
		return "/applyLoan/loanList";
	}
	
	@RequestMapping(value = "/applyLoan/loanDetails")
	public String loanDetails() {
		ViewContext.put("hotHM", "loanDetailsHM");
		return "/applyLoan/loanDetails";
	}
	@RequestMapping(value = "/loanApply/loans")
	public String loans() {
		return "/applyLoan/loading";
	}
	@RequestMapping(value = "/loanApply/manageMoney")
	public String manageMoney() {
		return "/applyLoan/manageMoney";
	}
	@RequestMapping(value = "/applyLoan/applySuccess")
	public String applySuccess() {
		return "/applyLoan/applySuccess";
	}
	
	
	
}
